// components/ml-checkboxes/ml-checkboxes.js
Component({
  options: {
    styleIsolation: 'isolated'
  },
  /**
   * 组件的属性列表
   */
  properties: {
    options: {
      type: Array,
      value: [],
    },
    value: {
      type: Array,
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    handleSelect(event) {
      const option = event.currentTarget.dataset.option;
      let value = [...this.data.value];
      if(value.includes(option.value)) {
        value = value.filter(item => item !== option.value);
      } else {
        value.push(option.value);
      }
      this.triggerEvent('change', value);
    }
  }
})
